package com.blb.thread;

/**
 * 自定义线程
 */
class MyThread extends Thread{

    //实现run方法
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + "--->" + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Demo1Thread {

    public static void main(String[] args) {
//        for (int i = 0; i < 10; i++) {
//            //创建自定义线程对象
//            MyThread myThread = new MyThread();
//            //启动线程
//            myThread.start();
//        }
        for(;;){
            System.out.println("hello");
            try {
                Thread.sleep(1);
                //中断异常
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
